//
//  AdoptedPayPigDetailsCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/9/5.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "AdoptedPayPigDetailsCell.h"

@implementation AdoptedPayPigDetailsCell

#pragma mark - lifecycle methods

- (void)setupUI{
    
    [self addSubview:self.pigIcon];
    [self addSubview:self.pigNumLab];
    [self addSubview:self.pigNameLab];
    [self addSubview:self.priceLab];
    
}

- (void)setupLayout{
    
    {
        _pigIcon.size = CGSizeMake(92, 64);
        _pigIcon.mj_x = 15;
        _pigIcon.mj_y = 18;
    }
    
    {
        _pigNameLab.size = CGSizeMake(KScreenWidth - _pigIcon.right - 25, 21);
        _pigNameLab.mj_y = 18;
        _pigNameLab.mj_x = _pigIcon.right + 10;
    }
    
    {
        _pigNumLab.size = CGSizeMake(_pigNameLab.width, 20);
        _pigNumLab.mj_x = _pigNameLab.left;
        _pigNumLab.mj_y =  _pigNameLab.bottom + 5;
    }
    
    {
        _priceLab.size = _pigNumLab.size;
        _priceLab.mj_x = _pigNumLab.mj_x;
        _priceLab.mj_y = 62;
    }

}

#pragma mark - setter methods
- (void)setPrice:(NSString *)price{
    
    NSString *text = [NSString stringWithFormat:@"¥%@", price];
    
    NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]initWithString:text];
    [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xF25C62) range:NSMakeRange(0, text.length)];
    [attributedString addAttribute:NSFontAttributeName value:mBlodFont(12) range:NSMakeRange(0, text.length)];
    [attributedString addAttribute:NSFontAttributeName value:mBlodFont(19) range:NSMakeRange(1, text.length - 4)];
    _priceLab.attributedText = attributedString;
    
}


#pragma mark - getter methods

- (UIImageView *)pigIcon{
    
    if (!_pigIcon) {
        _pigIcon = [[UIImageView alloc] init];
    }
    return _pigIcon;
}

- (UILabel *)pigNameLab{
    
    if (!_pigNameLab) {
        _pigNameLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x121212) font:mFont(15) textAliment:0];
    }
    return _pigNameLab;
}

- (UILabel *)pigNumLab{
    
    if (!_pigNumLab) {
        _pigNumLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0x8D8D8D) font:mFont(14) textAliment:0];
    }
    return _pigNumLab;
}

- (UILabel *)priceLab{
    
    if (!_priceLab) {
        _priceLab = [UILabel makeLabelWithText:@"" textColor:UIColorFromRGB(0xF25C62) font:mFont(17) textAliment:2];
    }
    return _priceLab;
}

@end

